<?php
/**
 * Created by PhpStorm.
 * User: W
 * Date: 2018/12/5
 * Time: 11:18
 */

namespace app\sports_admin\model;


use think\Model;
use think\Request;

class TableChapter extends Model
{
    protected $table = "table_chapter";

    protected $pk    = "id";

    protected $autoWriteTimestamp = true;
    //关联视频表
    public function getTableVideo()
    {
        return $this->belongsTo('TableVideo','catid','id');
    }
    //添加章节
    public static function addSectionMessage()
    {
        $message = Request::instance()->only(['cat_id','zjtitle']);
        return self::create(['catid'=>$message['cat_id'],'zjtitle'=>$message['zjtitle']]);

    }
    //删除章节
    public static function delSection($request)
    {
        $message = Request::instance()->only(['id']);
        return self::where('id',$message['id'])->delete();
    }
}